1 From 5189446ba995556eaa3755a6e875bc06675b88bd Mon Sep 17 00:00:00 2001
2 From: Oscar Maes <oscmaes92@gmail.com>
3 Date: Wed, 27 Aug 2025 08:23:21 +0200
4 Subject: [PATCH] net: ipv4: fix regression in local-broadcast routes
6 Commit 9e30ecf23b1b ("net: ipv4: fix incorrect MTU in broadcast routes")
7 introduced a regression where local-broadcast packets would have their
8 gateway set in __mkroute_output, which was caused by fi = NULL being
11 Fix this by resetting the fib_info for local-broadcast packets. This
12 preserves the intended changes for directed-broadcast packets.
14 Cc: stable@vger.kernel.org
15 Fixes: 9e30ecf23b1b ("net: ipv4: fix incorrect MTU in broadcast routes")
16 Reported-by: Brett A C Sheffield <bacs@librecast.net>
17 Closes: https://lore.kernel.org/regressions/20250822165231.4353-4-bacs@librecast.net
18 Signed-off-by: Oscar Maes <oscmaes92@gmail.com>
19 Reviewed-by: David Ahern <dsahern@kernel.org>
20 Link: https://patch.msgid.link/20250827062322.4807-1-oscmaes92@gmail.com
21 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
23 net/ipv4/route.c | 10 +++++++---
24 1 file changed, 7 insertions(+), 3 deletions(-)
26 --- a/net/ipv4/route.c
27 +++ b/net/ipv4/route.c
28 @@ -2532,12 +2532,16 @@ static struct rtable *__mkroute_output(c
29 !netif_is_l3_master(dev_out))
30 return ERR_PTR(-EINVAL);
32 - if (ipv4_is_lbcast(fl4->daddr))
33 + if (ipv4_is_lbcast(fl4->daddr)) {
35 - else if (ipv4_is_multicast(fl4->daddr))
37 + /* reset fi to prevent gateway resolution */
39 + } else if (ipv4_is_multicast(fl4->daddr)) {
41 - else if (ipv4_is_zeronet(fl4->daddr))
42 + } else if (ipv4_is_zeronet(fl4->daddr)) {
43 return ERR_PTR(-EINVAL);
46 if (dev_out->flags & IFF_LOOPBACK)